/**
 * 概况图表
 */
$(function() {
	
	orderFormChartDay("day");
	
	var feedBackPieChart = echarts.init(document.getElementById('feed-back-pie-chart'));
	$.getJSON('getFeedBackPieChartData').done(function(data) {
		feedBackPieChart.setOption({
			 title : {
			        text: '用户反馈处理统计图',
			        subtext: '用户反馈处理统计图',
			        x:'center'
			    },
			    tooltip : {
			        trigger: 'item',
			        formatter: "{a} <br/>{b} : {c} ({d}%)"
			    },
			    legend: {
			        orient: 'vertical',
			        left: 'left',
			        data: ['已处理','未处理']
			    },
			    series : [
			        {
			            name: '处理数',
			            type: 'pie',
			            radius : '55%',
			            center: ['50%', '60%'],
			            data:data.series,
			            itemStyle: {
			                emphasis: {
			                    shadowBlur: 10,
			                    shadowOffsetX: 0,
			                    shadowColor: 'rgba(0, 0, 0, 0.5)'
			                }
			            }
			        }
			    ]
		});
	});
	
	
	var echartsMapChart = echarts.init(document.getElementById('echarts-map-chart'));
	$.getJSON('getRegionDocChartData').done(function(data) {
		echartsMapChart.setOption({
			
			title: {
		        text: '注册医生分布图',
		        subtext: '最新数据',
		        left: 'center'
		    },
		    tooltip: {
		        trigger: 'item'
		    },
		    visualMap: {
		        min: 0,
		        max: 500,
		        left: 'left',
		        top: 'bottom',
		        text: ['多','少'],           // 文本，默认为数值文本
		        calculable: true
		    },
		    toolbox: {
		        show: true,
		        orient: 'vertical',
		        left: 'right',
		        top: 'center',
		        feature: {
		            dataView: {readOnly: false},
		            restore: {},
		            saveAsImage: {}
		        }
		    },
		    series: [
		        {
		            name: '注册量',
		            type: 'map',
		            mapType: 'china',
		            roam: false,
		            label: {
		                normal: {
		                    show: true
		                },
		                emphasis: {
		                    show: true
		                }
		            },
		            data:data
		        }
		    ]
			
			
			
		});
	});
	
	
});


function 	orderFormChartDay(date){
	var orderFormChart= echarts.init(document.getElementById('order-form-chart'));
	var url = "";
	if(date=="day"){
		url = "getOrderFormChartData?type="+date;
	}else if(date =="Weeks"){   // 周
		url = "getOrderFormChartData?type="+date;
	}else if(date =="Month"){   // 月
		url = "getOrderFormChartData?type="+date;
	}
	
	$.getJSON(url).done(function(data) {

		orderFormChart.setOption({
		    toolbox: {
		        show : true,
		        feature : {
		            magicType : {show: true, type: ['line', 'bar']},
		           }
			},
			title : {
	        	text: '订单统计图',
		        subtext: '',
		        left: 'center',
	        },
	        color: ['#3398DB'],
	        tooltip : {
	        	borderColor : "#FFFFAA ",
        		borderWidth: 1,
	        	borderRadius: 10,
	        	
	        	trigger: 'axis',
	            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
	                type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
	            }
	        }, 
	        grid: {//控制边距
	            left: '2%',
	            right: '5%',
	            bottom: '10%',
	            containLabel: true
	        },
	        xAxis : [
	            {
	                name: "时间",
	            	type : 'category',
	                data :data.createTime,
	                axisLabel :{
	                	formatter:'{value}',//间隔名称格式器
	                	interval:0,//标签显示间隔
	                	rotate:10,//旋转角度
	                	margin:10,
	                	textStyle:{
	                		color:"nave",//刻度颜色
	                		fontSize:10//字体大小
	                	}
	                }
	            }
	        ],
	        
	        yAxis : [
	            {
	            	name:'人数/个',
	                type : 'value',
	                axisLabel:{formatter:'{value}'},
	                splitNumber:4
	            }
	        ],
	        series : [
	            {
	                name:'订单量',
	                type:'bar',
	                barWidth: '30',
	                itemStyle: {
	                	normal: {
	                		color:'rgba(193,35,43,1)', 
	                		label:{show:true},
	                		 barBorderRadius: 10
	                	},
//	                	emphasis: {//鼠标出发时，数据颜色变化
//                            barBorderColor:'rgba(193,35,43,1)',
//                            color: 'blue'  
//	                    }
	                },
	                data:data.orderNum,
	            }
	        
	        ]
	        
	    });
	});
}


